rm(list = ls())
gc()
# wd <- 'C:/Users/Jimbo/Dropbox/FED/FED/Paper/JOP/CA_replication'
wd <- 'C:/Users/bisbeejh/Dropbox/Apps/Overleaf/Political_Geography_LongPaper_PSRM/replication'
# wd <- 'D:/Dropbox/FED/FED/Paper/JOP/CA_replication/'

setwd(wd)
set.seed(123)

################################################################################
##
## Run replication scripts
##
################################################################################
fs <- list.files('./code',pattern = '^fig')
for(f in fs) {
  # stop()
  cat(f,'\n')
  zz <- Sys.time()
  print(system(paste0('R CMD BATCH --no-save --no-restore "--args ',
                      '" ./code/',f," ./code/LOG/",gsub('\\.R','_LOG.txt',f))))
  dur <- Sys.time() - zz
  print(dur)
  # If this doesn't print a zero, there is an error
}

# EOF